package cn.cxion.chat.app.util;

import android.os.SystemClock;
import android.widget.Chronometer;

public class ChronometerUtil {

    public static void setFormat(Chronometer chronometer) {
        LogUtil.print("base=="+chronometer.getBase());
        int hour = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60 / 60);
        int minute = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60) % 60;
        int second = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000) % 60;
        if (hour < 1) {
            if (minute == 59 && second == 59) {
                chronometer.setFormat("已认领："+"0" + "%s");
            } else {
                chronometer.setFormat("已认领："+"0" + String.valueOf(hour) + ":%s");
            }
        } else if (hour < 10) {
            chronometer.setFormat("已认领："+"0" + "%s");
        } else {
            chronometer.setFormat("已认领：%s");
        }
    }

}
